package pe.edu.upc.dsd.whereeat.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import pe.edu.upc.dsd.whereeat.base.dao.impl.BaseDAOImpl;
import pe.edu.upc.dsd.whereeat.dao.PlatoDAO;
import pe.edu.upc.dsd.whereeat.domain.Plato;

@Repository
public class PlatoDAOImpl extends BaseDAOImpl<Plato, Integer> implements
		PlatoDAO {

	public Plato find(Plato object) throws Exception {
		String queryString = "SELECT p from Plato p where p.codigo=?";
		return findSingleObject(queryString,
				new Object[] { object.getCodigo() });
	}

	@Override
	public List<Plato> obtenerPlatosPorRestaurantId(int restaurantId)
			throws Exception {

		String queryString = "select x from Plato x where x.restaurant.codigo=?";

		return executeQuery(queryString, new Object[] { restaurantId });

	}
	
}
